#ifndef LINESHARE_H
#define LINESHARE_H

#include <QtNetwork/QAbstractSocket>
#include <QtNetwork/QHostAddress>
#include <QtNetwork/QHostInfo>
#include <QtNetwork/QNetworkAddressEntry>
#include <QtNetwork/QTcpServer>
#include <QtNetwork/QTcpSocket>
#include <QtNetwork/QUdpSocket>
#include <QtNetwork/QNetworkConfiguration>
#include <QtNetwork/QNetworkConfigurationManager>
#include <QtNetwork/QNetworkSession>
#include <QObject>
#include <QVector>
#include <QColor>
#include <QPainter>
#include <QPen>
#include <QDebug>


#include "stroke.h"
#include "client.h"

/* Lineshare class
 *
 * Users access point to our library
 */

class LineShare : public QObject
{
    Q_OBJECT
public:
    explicit LineShare(QObject *parent = 0);// Construct the object
    // Public so the user can manipulate as necessary
    QVector<Stroke> m_commonStrokes;        // Strokes shared between users
    Stroke m_currentStroke;                 // Stroke user is currently manipulating

    void setupNetwork();   // Initialize network setting for this app

    void addPoint(QPoint);                  // Add a point to current stroke vector
    void addPoint(int x, int y);            // Add a point to current stroke vector
    void clear();                           // Clears the shared stroke vector, sends clear msg

    int getCurrentR();                      // Get the current color settings of the pen
    int getCurrentG();
    int getCurrentB();
    int getCurrentPenWidth();               // Get current width settings of the pen
    QDateTime getCurrentDateTime();         // Get current date/time

    void setCurrentR(int r);                // Set Pen color components RGB
    void setCurrentG(int g);                //
    void setCurrentB(int b);                //
    void setCurrentColor(int r, int g, int b);// Set Pen color components RGB
    void setCurrentColor(QColor);           // Set Color
    void setCurrentPenWidth(int width);     // Set Width
    void setCurrentDateTime(QDateTime timestamp);   // Set date time

    void sharePainter(QPainter *);          // Used to pass the canvas painter to the lib
    void drawWithPainter();                 // Draw with shared painter - for user.  Immediate, but overlap in timing order

signals:
    void sendMessage(QString);              // Outgoing message to network component
    void repaint();                         // State of shared vector has changed, repaint
    void strokeReceived(Stroke);            // New stroke received
    void clearReceived(void);               // Clear msg received

public slots:
    void strokeComplete();                  // User finished with current stroke
    void receiveMessage(QString);           // Revieve incoming message from network component

private:
    QPainter * m_painter;                   // Users canvas painter for lib to paint with
    Client client;                          // Network connection and interface
};

#endif // LINESHARE_H
